#include <stdio.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/0c83231923c541d2aa15861571831ee5?tpId=290&tqId=320958&ru=/exam/oj/ta&qru=/ta/beginner-programmers/question-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

typedef struct Matrix {
    int N;
    int Mat[0];
}Matrix;

int main() {
    int row = 0;
    int col = 0;
    int sum = 0;
    scanf("%d%d", &row, &col);
    //开辟柔性数组
    Matrix *arr = (Matrix *) malloc(sizeof(Matrix) + row * col * sizeof(int));
    if (arr == NULL) {
        perror("堆区开辟空间失败:");
    }
    arr->N = row * col;
    //柔性数组的使用
    for (int i = 0; i < row * col; i++) {
        scanf("%d", &arr->Mat[i]);
        if (arr->Mat[i] > 0) {
            sum += arr->Mat[i];
        }
    }
    printf("%d", sum);
    //释放柔性数组
    free(arr);
    arr = NULL;
    return 0;
}